package com.foreknow.elmboot.controller;

import com.foreknow.elmboot.po.Cart;
import com.foreknow.elmboot.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/CartController")
public class CartController {
    @Autowired
    private CartService cartService;
    @RequestMapping("/listCart")
    public List<Cart> getCart(Integer businessId,String userId){
        List<Cart> cart = cartService.getCart(businessId,userId);
        return cart;
    }

    @RequestMapping("/saveCart")
    public int insertCart(Integer cartId,Integer userId,Integer foodId,Integer businessId){

        int num = cartService.insertCart(cartId,userId,foodId,businessId);
        return num;
    }
    @RequestMapping("/updateCart")
    public int updateCart(Integer quantity,Integer userId,Integer foodId,Integer businessId){
        int num = cartService.updateCart(quantity,userId,foodId,businessId);
        return num;
    }

    @RequestMapping("/removeCart")
    public int deleteCart(Cart cart){
        int num = cartService.deleteCart(cart);
        return num;
    }

}
